﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using StockShark.Models;

namespace StockShark.BusinessModels
{
    public class GameProperties
    {
        // prowizje maklerskie
        public const decimal SharesBrokerage = 0.35M; // % wartosci transakcji
        public const decimal SharesBrokerageMin = 3.00M; // minimalna oplata
        public const decimal CurrenciesBrokerage = 0.25M; // % wartosci transakcji
        public const decimal CurrenciesBrokerageMin = 3.00M; // minimalna oplata
        public const decimal MaterialsBrokerage = 0.25M; // % wartosci transakcji
        public const decimal MaterialsBrokerageMin = 6.00M; // minimalna oplata
        public const decimal OthersBrokerage = 0.45M; // % wartosci transakcji
        public const decimal OthersBrokerageMin = 9.00M; // minimalna oplata

        public static decimal CalculateCommission(decimal value, string type)
        {
            decimal brokerage, brokerageMin;
            if (type.ToLower().Equals("share"))
            {
                brokerage = SharesBrokerage;
                brokerageMin = SharesBrokerageMin;
            }
            else if (type.ToLower().Equals("currency"))
            {
                brokerage = CurrenciesBrokerage;
                brokerageMin = CurrenciesBrokerageMin;
            }
            else if (type.ToLower().Equals("material"))
            {
                brokerage = MaterialsBrokerage;
                brokerageMin = MaterialsBrokerageMin;
            }
            else
            {
                brokerage = OthersBrokerage;
                brokerageMin = OthersBrokerageMin;
            }
            return Math.Max(value * brokerage / 100, brokerageMin);
        }

        public static bool MarketOpen()
        {
            DateTime today = DateTime.Today;
            if (today.DayOfWeek == DayOfWeek.Sunday || today.DayOfWeek == DayOfWeek.Saturday)
                return false;
            return true;
        }
    }


}